package com.feri.fitness.cs.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.feri.fitness.cs.domain.Mood;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 千锋郑州Java学科欢迎你
 * @program: Fitness
 * @description: 持久层 定义操作数据库的方法
 * @author: Feri
 * @create: 2023-01-12 08:59:28
 */
public interface MoodDao extends BaseMapper<Mood> {

    @Select("select count(*) num from t_mood where parentid in (select id from t_mood where uid=#{uid} and date_format(ctime,'%Y-%m-%d')=#{day})")
    long selectNum(@Param("uid") int uid,@Param("day") String day);
    @Select("select m.* from t_mood m inner join t_user_follow u on m.uid=u.fuid where u.uid=#{uid} and m.looktype between 1 and 2 order by m.ctime desc")
    List<Mood> selectFollow(int uid);

    @Update("update t_mood set flag=2 where id=#{id}")
    int del(int id);
}